package mviewer.renderer.software.swing;

import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import java.awt.Graphics;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import mviewer.renderer.software.SoftwareRenderer;

public class RendererView extends JComponent {

	// ViewUI inner class definition
	public class ModelViewUI extends ComponentUI {

		@Override
		public Dimension getMinimumSize(JComponent jc) {
			return new Dimension(600, 400);
		}

		@Override
		public void paint(final Graphics g, JComponent jc) {
			BufferedImage img = renderer.getImage();
			g.drawImage(img, 0, 0, jc.getWidth(), jc.getHeight(), null);
		}
	}

	private SoftwareRenderer renderer;

	public RendererView(SoftwareRenderer renderer) {
		super();
		this.renderer = renderer;
		setOpaque(true);
		setUI(new ModelViewUI());
	}
}